import Cookies from 'js-cookie'
import store  from '@/store/index'

const TokenKey = 'token'

export function getToken() {
    let t = Cookies.get(TokenKey)
    if(t){
        return t
    }else if(store?.state?.token){
        setToken(store?.state?.token)
        return store?.state?.token
    }else{
        return
    }  
}

export function setToken(token) {
  return Cookies.set(TokenKey, token)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}
